home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 February / PCWFEB08.iso / Software / Resources / Developers / XAMPP 1.5.4 / Windows installer / xampp-win32-1.5.4-installer.exe / xampp / php / pear / CodeGen / Element.php < prev    next >
Encoding:
PHP Script  |  2006-04-07  |  4.6 KB  |  226 lines

  1. <?php
  2. /**
  3.  * Abstract base class for all code elements
  4.  *
  5.  * PHP versions 5
  6.  *
  7.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  8.  * that is available through the world-wide-web at the following URI:
  9.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  10.  * the PHP License and are unable to obtain it through the web, please
  11.  * send a note to license@php.net so we can mail you a copy immediately.
  12.  *
  13.  * @category   Tools and Utilities
  14.  * @package    CodeGen
  15.  * @author     Hartmut Holzgraefe <hartmut@php.net>
  16.  * @copyright  2005 Hartmut Holzgraefe
  17.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  18.  * @version    CVS: $Id: Element.php,v 1.5 2006/02/17 09:47:00 hholzgra Exp $
  19.  * @link       http://pear.php.net/package/CodeGen
  20.  */
  21.  
  22. /**
  23.  * Abstract base class for all code elements
  24.  *
  25.  * @category   Tools and Utilities
  26.  * @package    CodeGen
  27.  * @author     Hartmut Holzgraefe <hartmut@php.net>
  28.  * @copyright  2005 Hartmut Holzgraefe
  29.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  30.  * @version    Release: @package_version@
  31.  * @link       http://pear.php.net/package/CodeGen
  32.  */
  33. abstract class CodeGen_Element 
  34. {
  35.     /**
  36.      * The function name
  37.      *
  38.      * @var     string
  39.      */
  40.     protected $name  = "unknown";
  41.  
  42.     /**
  43.      * Name setter
  44.      *
  45.      * @param  string  function name
  46.      * @return bool    success status
  47.      */
  48.     function setName($name) 
  49.     {
  50.         $this->name = $name;
  51.             
  52.         return true;
  53.     }
  54.  
  55.  
  56.     /**
  57.      * Name getter
  58.      *
  59.      * @return  string  function name
  60.      */
  61.     function getName() 
  62.     {
  63.         return $this->name;
  64.     }
  65.  
  66.  
  67.     /**
  68.      * A short description
  69.      *
  70.      * @var     string
  71.      */
  72.     protected $summary = "";
  73.  
  74.     /**
  75.      * Summary setter
  76.      *
  77.      * @param  string  function summary
  78.      * @return bool    success status
  79.      */
  80.     function setSummary($text)
  81.     {
  82.         $this->summary = $text;
  83.         return true;
  84.     }
  85.  
  86.  
  87.  
  88.  
  89.     /**
  90.      * A long description
  91.      *
  92.      * @var     string
  93.      */
  94.     protected $description  = "";
  95.  
  96.     /**
  97.      * Description setter
  98.      *
  99.      * @param  string  function description
  100.      * @return bool    success status
  101.      */
  102.     function setDescription($text)
  103.     {
  104.         $this->description = $text;
  105.         return true;
  106.     }
  107.  
  108.  
  109.     /**
  110.      * Checks whether a string is a reserved name
  111.      *
  112.      * @access public
  113.      * @param  string name
  114.      * @return bool   true if reserved
  115.      */
  116.     function isKeyword($name) 
  117.     {
  118.         return false;
  119.     }
  120.  
  121.  
  122.  
  123.     /**
  124.      * Checks whether a string is a valid C name
  125.      *
  126.      * @access public
  127.      * @param  string The name to check
  128.      * @return bool   true for valid names, false otherwise
  129.      */
  130.     function isName($name) 
  131.     {
  132.         if (preg_match('|^[a-z_]\w*$|i',$name)) {
  133.             // TODO reserved words
  134.             return true;
  135.         } 
  136.         return false;
  137.     }
  138.  
  139.     /**
  140.      * Generate C code for element
  141.      *
  142.      * @access  public
  143.      * @param   string Extension name
  144.      * @return  string C code 
  145.      */
  146.     function cCode($name)
  147.     {
  148.         return ""; 
  149.     }
  150.  
  151.     /**
  152.      * Generate C code header block for all elements of this class
  153.      *
  154.      * @access public
  155.      * @param  string Extension name
  156.      * @return string C code
  157.      */
  158.     static function cCodeHeader($name) 
  159.     {
  160.         return "";
  161.     }
  162.  
  163.     /**
  164.      * Generate C code footer block for all elements of this class
  165.      *
  166.      * @access public
  167.      * @param  string Extension name
  168.      * @return string C code
  169.      */
  170.     static function cCodeFooter($name) 
  171.     {
  172.         return "";
  173.     }
  174.  
  175.     /**
  176.      * Generate C include file definitions for element
  177.      *
  178.      * @access  public
  179.      * @param  class Extension  extension we are owned by
  180.      * @return  string C header code 
  181.      */
  182.     function hCode($extension) 
  183.     {
  184.         return "";
  185.     }
  186.  
  187.     /**
  188.      * Generate documentation code for element
  189.      *
  190.      * @access  public
  191.      * @param   string id basename for extension
  192.      * @return  string documentation content
  193.      */
  194.     function docEntry($extension)
  195.     {
  196.         return "";
  197.     }
  198.  
  199.     /**
  200.      * Generate documentation header block for all elements of this class
  201.      *
  202.      * @access public
  203.      * @param  string Extension name
  204.      * @return string documentation fragment
  205.      */
  206.     static function docHeader($name) 
  207.     {
  208.         return "";
  209.     }
  210.  
  211.     /**
  212.      * Generate documentation footer block for all elements of this class
  213.      *
  214.      * @access public
  215.      * @param  string Extension name
  216.      * @return string documentation fragment
  217.      */
  218.     static function docFooter($name) 
  219.     {
  220.         return "";
  221.     }
  222.  
  223. }
  224.  
  225. ?>
  226.